package ru.spb.nicetu.altx.mnemo.math.managers;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import ru.spb.nicetu.altx.mnemo.extpoint.model.funcs.ISimpleFuncFactory;

public class SimpleFuncFactoryManager {
  protected SimpleFuncFactoryManager() {
  }

  private static SimpleFuncFactoryManager instance = new SimpleFuncFactoryManager();

  public static SimpleFuncFactoryManager getInstance() {
    return instance;
  }

  private List<ISimpleFuncFactory> simpleFuncFactories = new ArrayList<ISimpleFuncFactory>();

  private Map<String, ISimpleFuncFactory> simpleFuncFactoriesMap = new HashMap<String, ISimpleFuncFactory>();

  public void addSimpleFuncFactory(ISimpleFuncFactory factory) {
    simpleFuncFactories.add(factory);
    simpleFuncFactoriesMap.put(factory.getSimpleFuncClassName(), factory);
  }

  public ISimpleFuncFactory[] getAllSimpleFuncFactories() {
    return simpleFuncFactories.toArray(new ISimpleFuncFactory[0]);
  }

  public void addSimpleFuncFactory(String name, ISimpleFuncFactory factory) {
    simpleFuncFactoriesMap.put(name, factory);
  }

  public ISimpleFuncFactory getFactory(String name) {
    return simpleFuncFactoriesMap.get(name);
  }

}
